#include "Bear.h"

#include "Error.h"

void Bear::addObject( BBObject* newObject )
{
	QString name( newObject->getName() );

	m_objects[name] = newObject;
	m_initializationOrder.append( name );
}

QList<BBObject*> Bear::getObjectsInitializationOrder()
{
	QList<BBObject*> list;
	QListIterator<QString> iteratorOrder( m_initializationOrder );

	while ( iteratorOrder.hasNext() )
	{
		list.append( m_objects[iteratorOrder.next()] );
	}

	return list;
}

QList<BBObject*> Bear::getObjectsInitializationOrderReversed()
{
	QList<BBObject*> list;

	QList<QString> initializationOrder( m_initializationOrder );

	while ( !initializationOrder.empty() )
	{
		list.append( m_objects[initializationOrder.takeLast()] );
	}

	return list;
}

